package com.onLineCar.file.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;



/**
 * Oss 配置信息
 *
 * @author onLineCar
 */
@Configuration
@ConfigurationProperties(prefix = "oss")
public class OssConfig {
    /**
     * 存储对象概述
     */
    private String endPoint;

    /**
     * 阿里云主账号
     */
    private String accessKeyId;

    /**
     * 拥有所有API的访问权限
     */
    private String accessKeySecret;

    /**
     * 存储桶名称
     */
    private String accessPre;
    /**
     * bucket名称
     */
    private String bucketName;

    public String getEndPoint() {
        return endPoint;
    }

    public void setEndPoint(String endPoint) {
        this.endPoint = endPoint;
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
    }

    public String getAccessPre() {
        return accessPre;
    }

    public void setAccessPre(String accessPre) {
        this.accessPre = accessPre;
    }

    public String getBucketName() {
        return bucketName;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }


    @Bean
    public OSS ossClient () {
        return new OSSClientBuilder().build(endPoint,
                accessKeyId,
                accessKeySecret);
    }
}
